3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
To write a drawing engine, you need to implement several private methods for managing bitmaps. If your engine supports texture mapping, you also need to implement several private methods for managing textures.
Pointers to your drawing engine's texture and bitmap methods are returned to QuickDraw 3D RAVE by your TQAEngineGetMethod method. See page [link] for details.
A drawing engine may define a method to create a new texture map. This method is optional and must be supported only by drawing engines that support texture mapping.
typedef TQAError (*TQATextureNew) (
unsigned long flags,
TQAImagePixelType pixelType,
const TQAImage images[],
TQATexture **newTexture);
Your TQATextureNew function is called whenever an application calls QATextureNew . Your function should perform any tasks required to use the texture in texture-mapping operations. This might involve loading the texture into memory on the device associated with your drawing engine. If so, your TQATextureNew function should not return until the texture has been completely loaded.
The flags parameter specifies a set of texture map features. If the kQATexture_Lock bit in that parameter is set but your drawing engine cannot guarantee that the texture will remain locked in memory, your TQATextureNew function should return an error.
If the kQATexture_Mipmap bit of the flags parameter is clear, the images parameter points to a single pixel image that defines the texture map. If the kQATexture_Mipmap bit is set, the images parameter points to an array of pixel images of varying pixel depths. The first element in the array must be the mipmap page having the highest resolution, with a width and height that are even powers of 2. Each subsequent pixel image in the array should have a width and height that are half those of the previous image (with a minimum width and height of 1).
A drawing engine may define a method to detach a texture map. This method is optional and must be supported only by drawing engines that support texture mapping.
typedef TQAError (*TQATextureDetach) (TQATexture *texture);
Your TQATextureDetach function is called whenever an application calls QATextureDetach . Your function should, if necessary, load the texture specified by the texture parameter into memory on the device associated with your drawing engine (so that the caller can release the memory occupied by the texture). Your TQATextureDetach function should not return until the texture has been completely loaded.
A drawing engine may define a method to bind a color lookup table to a texture map.
typedef TQAError (*TQATextureBindColorTable) (
TQATexture *texture,
TQAColorTable *colorTable);
Your TQATextureBindColorTable function is called whenever an application calls QATextureBindColorTable . Your function should bind the color lookup table specified by the colorTable parameter to the texture map specified by the texture parameter. Note that the type of the specified color lookup table must match that of the pixel type of the texture map to which it is bound. For example, a color lookup table of type kQAColorTable_CL8_RGB32 can be bound only to a texture map whose pixel type is kQAPixel_CL8 .
A drawing engine may define a method to delete a texture map. This method is optional and must be supported only by drawing engines that support texture mapping.
typedef void (*TQATextureDelete) (TQATexture *texture);
A drawing engine must define a method to create a new bitmap.
typedef TQAError (*TQABitmapNew) (
unsigned long flags,
TQAImagePixelType pixelType,
const TQAImage *image,
TQABitmap **newBitmap);
Your TQABitmapNew function is called whenever an application calls QABitmapNew . Your function should perform any tasks required to draw the bitmap in the draw context associated with your drawing engine. This might involve loading the bitmap into memory on the device associated with your drawing engine. If so, your TQABitmapNew function should not return until the bitmap has been completely loaded.
The flags parameter specifies a set of bitmap features. If the kQABitmap_Lock bit in that parameter is set but your drawing engine cannot guarantee that the bitmap will remain locked in memory, your TQABitmapNew function should return an error.
A drawing engine must define a method to detach a bitmap from a drawing engine.
typedef TQAError (*TQABitmapDetach) (TQABitmap *bitmap);
Your TQABitmapDetach function is called whenever an application calls QABitmapDetach . Your function should, if necessary, load the bitmap specified by the bitmap parameter into memory on the device associated with your drawing engine (so that the caller can release the memory occupied by the bitmap). Your TQABitmapDetach function should not return until the bitmap has been completely loaded.
A drawing engine may define a method to bind a color lookup table to a bitmap.
typedef TQAError (*TQABitmapBindColorTable) (
TQABitmap *bitmap,
TQAColorTable *colorTable);
Your TQABitmapBindColorTable function is called whenever an application calls QABitmapBindColorTable . Your function should bind the color lookup table specified by the colorTable parameter to the bitmap specified by the bitmap parameter. Note that the type of the specified color lookup table must match that of the pixel type of the bitmap to which it is bound. For example, a color lookup table of type kQAColorTable_CL8_RGB32 can be bound only to a bitmap whose pixel type is kQAPixel_CL8 .
A drawing engine must define a method to delete a bitmap.
typedef void (*TQABitmapDelete) (TQABitmap *bitmap);
Previous | QD3D Book | Overview | Chapter Contents | Next |